define at3_nfssrv($share_root,$clientlist, $share_options = "rw,sync,no_root_squash") {

  file { $share_root:
    ensure => directory,
    owner => "root",
    group => "root",
    mode => 755,
  }
  
  file { "/etc/exports":
    owner => "root",
    group => "root",
    mode => 644,
    content => template("at3_nfs/etc-exports.tpl"),
    notify => Service["nfs"],
  }
  
  package { "nfs-utils":
    ensure => installed,
  }
  
  service { [ "nfs", "nfslock", "portmap"]:
    hasstatus => true,
    hasrestart => true,
    ensure => running,
    enable => true,
    require => [Package["nfs-utils"],File[$share_root],File["/etc/exports"]]
  }
  
}

class nfs_client {
  package { "nfs-utils":
    ensure => installed,
  }
  service { [ "nfs", "nfslock", "portmap"]:
    ensure => running,
    enable => true,
    require => Package["nfs-utils"],
    hasstatus => true,
    hasrestart => true,
  }
}

define at3_nfsclient($source,$dest) {

  include nfs_client

  exec { "create_mountpoint_${dest}":
    command => "mkdir -p $dest",
  }
  
  file { $dest:
    ensure => directory,
    owner => "root",
    group => "root",
    mode => 755,
    require => Exec[ "create_mountpoint_${dest}"],
  }
  
  mount { $dest:
    atboot => true,
    device => $source,
    fstype => "nfs",
    name => $dest ,
    options => "defaults,rw,user,exec",
    ensure => "mounted",
    require => File[$dest],
  }
}

